import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Jsx from '@vitejs/plugin-vue-jsx'
import AutoImport from 'unplugin-auto-import/vite'

import { resolve } from 'path'

export default defineConfig({
  plugins: [
    vue(),
    Jsx(),
    AutoImport({
      imports: ['vue', 'vue-router'],
      dts: 'types/auto-import.d.ts'
    })
  ],

  server: {
    host: '0.0.0.0',
    port: 3000,
    open: false,
    https: false,
    base: './ ',
    proxy: {
      '^/api': {
        target: 'http://localhost',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },

  resolve: {
    alias: {
      '@': resolve(__dirname, './src')
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@/assets/css/variable.scss";`
      }
    }
  }
})
